#include <string>
using namespace std;

class Solution {
public:
    //中心扩展算法
    string longestPalindrome(string s) {
        int begin = 0,length = 0;
        
        for(int i = 0;i<s.size();++i)
        {
            //找长度为奇数的回文子串
           int left = i,right = i;
           while((left>=0 && right<s.size()) && (s[left] == s[right]))
           {
            left--;
            right++;
           }
           if(right-left-1 > length)
           {
            begin = left+1;
            length = right-left-1;
           }

            //找长度为偶数的回文子串
           left = i,right = i+1;
           while((left>=0 && right<s.size()) && (s[left] == s[right]))
           {
            left--;
            right++;
           }
           if(right-left-1 > length)
           {
            begin = left+1;
            length = right-left-1;
           }
        }
        return s.substr(begin,length);
    }
};
int main()
{
    int* p = new int[20]{0};
    return 0;
}